package com.wg.model;

import xyz.erupt.annotation.Erupt;
import xyz.erupt.annotation.EruptField;
import xyz.erupt.annotation.sub_erupt.Power;
import xyz.erupt.annotation.sub_field.Edit;
import xyz.erupt.annotation.sub_field.EditType;
import xyz.erupt.annotation.sub_field.View;
import xyz.erupt.annotation.sub_field.sub_edit.ChoiceType;
import xyz.erupt.jpa.model.BaseModel;
import xyz.erupt.toolkit.handler.SqlChoiceFetchHandler;

import javax.persistence.Entity;
import javax.persistence.Table;

@Erupt(name = "score", power = @Power(
        importable = true, export = true
))
@Table(name = "tb_scores")
@Entity
public class ScoreModel extends BaseModel {
    @EruptField(
            views = @View(title = "用户名"),
            edit = @Edit(
                    title = "用户名",
                    type = EditType.CHOICE,
                    choiceType = @ChoiceType(
                            fetchHandler = SqlChoiceFetchHandler.class,
                            fetchHandlerParams = {"select id, name from tb_users", "5000"}
                    )
            )
    )
    private Long userId;

    @EruptField(
            views = @View(title = "积分"),
            edit = @Edit(title = "积分")
    )
    private Integer score;

}
